﻿using Coldairarrow.Business.BackStage.ConsumeChats;
using Coldairarrow.Entity.BackStage.ConsumeChats;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.BackStage.ConsumeChats
{
    [Route("/BackStage/ConsumeChats/[controller]/[action]")]
    public class ChatContentController : BaseApiController
    {
        #region DI

        public ChatContentController(IChatContentBusiness chatContentBus)
        {
            _chatContentBus = chatContentBus;
        }

        IChatContentBusiness _chatContentBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<ChatContent>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _chatContentBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<ChatContent> GetTheData(IdInputDTO input)
        {
            return await _chatContentBus.GetTheDataAsync(input.Id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(ChatContent data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _chatContentBus.AddDataAsync(data);
            }
            else
            {
                await _chatContentBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _chatContentBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}